package com.qf.swagger2204.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * 定制swagger接口文档的配置类
 */
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        //创建需要的对象
        Docket docket = new Docket(DocumentationType.SWAGGER_2);
        //配置信息
        //建造者模式的实例
        ApiInfo apiInfo = new ApiInfoBuilder().title("My project").version("1.0.0")
                .description("这个项目的基本介绍写到这里")
                .contact(new Contact("鞠义", "http://www.4399.com", "123@123.com"))
                .build();//build方法会根据上面设置好的配置信息创建一个ApiInfo对象
        docket.apiInfo(apiInfo);
        //定制swagger只扫描我们自己项目的controller，不要扫描mvc
        docket.select().apis(RequestHandlerSelectors.basePackage("com.qf.swagger2204.controller")).build();

        //返回该对象
        return docket;
    }
}
